home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7666 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  64 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.dcs.warwick.ac.uk!not-for-mail
  3. From: D.C.Molero@dcs.warwick.ac.uk (Daniel Castillo Molero)
  4. Subject: linking c with tcl
  5. X-Nntp-Posting-Host: cocino
  6. Message-ID: <1996Feb28.020725.1195@dcs.warwick.ac.uk>
  7. Sender: news@dcs.warwick.ac.uk (Network News)
  8. Organization: Department of Computer Science, Warwick University, England
  9. Date: Wed, 28 Feb 1996 02:07:25 GMT
  10.  
  11.  
  12. Hi,
  13.  
  14. I'm trying to link a tcl application with some C code. It would be very
  15. helpful for me to learn how to link the tcl and c code below. The real
  16. application that I'm trying to link is more complex, but I think if you
  17. could teach me the principles behind with the code given here, I would
  18. be able to link my application.
  19.  
  20. The tcl code given here draws a horizontal line of variable length according
  21. to the number of times that the right cursor arrow is pressed.
  22. Then, the tcl application should call the c code to calculate the mid point
  23. of the line, and then again the tcl should draw a perpendicular to the
  24. original line.
  25.  
  26. I'll be extremely grateful to you for any help.
  27.  
  28. ---------------------------
  29. canvas .c
  30. pack .c
  31.  
  32. set x 2
  33. set y 2
  34. set i 1
  35. set hdist(1) 0.12345678; set hdist([expr $i+1]) 2; set hdist(3) 3.12345678
  36.  
  37. proc Segment {} {
  38. global x y i hdist
  39.   .c create line ${x}c ${y}c [expr $x+$hdist($i)]c ${y}c
  40.   set x [expr $x+$hdist($i)]
  41.   incr i
  42.   if { $i == 4 } { set i 1 }
  43. }
  44.  
  45. # here, I would like to include a call to the C code
  46. # to find the mid point of the line, and use it to draw
  47. # the perpendicular, for example like this:
  48. #     .c create line ${x}c 3 ${x}c 1
  49.  
  50. bind .c <Right> {Segment}
  51.  
  52. focus .c
  53.  
  54. --------------
  55. C code
  56.  
  57. main() {
  58.   x = x/2.0;
  59. }
  60. -- 
  61. * Daniel Castillo.  D.C.Molero@dcs.warwick.ac.uk *
  62.  
  63.  
  64.